<?php
/**
 * Created by PhpStorm.
 * User: yshang15
 * Date: 16/6/24
 * Time: 下午7:23
 */

namespace frontend\controllers;

use Yii;
use yii\web\Controller;

class MobileController extends Controller
{
    public function actionIndex()
    {
        $arr_mobile = file('/Users/yshang15/Public/webroot/zahuopuzi/frontend/web/mobile_code.txt');
        $arr_new = array();
        foreach($arr_mobile as $mobile) {
            $match = array();
            $preg = preg_match_all('/\d{11}/', $mobile, $match);
            if ($preg) {
                if (!in_array($match[0][0], $arr_new)) {
                    $arr_new[] = $match[0][0]."\n";
                }
            }
        }
        file_put_contents('/Users/yshang15/Public/webroot/zahuopuzi/frontend/web/mobile.txt',$arr_new);
    }

    public function actionMobile()
    {
        $arr_mobile = file('/Users/yshang15/Public/webroot/zahuopuzi/frontend/web/mobile.txt');
        $arr = array();
        foreach($arr_mobile as $mobile) {
            if (!in_array(trim($mobile), $arr) && preg_match('/^1/', $mobile)) {
                $arr[] = trim($mobile);
            }
        }
        file_put_contents('/Users/yshang15/Public/webroot/zahuopuzi/frontend/web/mobile_new.txt',join("\n", $arr));
    }
}